<template>
  <div class="home-banner">
    <!-- 传入数据 开启自动轮播 -->
    <XtxSlider :sliders="bannerList" :autoPlay="true"/>
  </div>
</template>

<script>
import { findBanner } from '@/api/home'
import { ref, onMounted } from 'vue'
export default {
  name: 'HomeBanner',
  // setup函数外不能包 async
  setup () {
    const bannerList = ref([])
    // 单独封装一个方法，方便参数修改
    async function loadBannerList () {
      const res = await findBanner()
      // console.log(res)
      bannerList.value = res.result
    }
    onMounted(() => {
      // 调用函数
      loadBannerList()
    })

    return { bannerList }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
